<template>
  <div>
    <el-dialog :visible.sync="visible">
      <el-table :data="dataList" align="center" header-align="center" fixed="right">
        <el-table-column prop="goodsId" label="编号" align="center" header-align="center"/>
        <el-table-column prop="name" label="商品名字" align="center" header-align="center"/>
        <el-table-column prop="getPrice" label="采购价格" align="center" header-align="center"/>
        <el-table-column prop="salePrice" label="售价" align="center" header-align="center"/>
        <el-table-column prop="goodsNum" label="库存" align="center" header-align="center"/>
        <el-table-column prop="getMan" label="采购人" align="center" header-align="center"/>
        <el-table-column prop="goodsTime" label="入库时间" align="center" header-align="center"/>
        <el-table-column prop="status" label="状态" align="center" header-align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status === 0" type="danger" size="small">禁用</el-tag>
            <el-tag v-else size="small">正常</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="pageIndex" :page-size="pageSize" :total="totalPage" :page-sizes="[10,20,30,50,100,200]" layout="total,sizes,prev,pager,next,jumper" @current-change="currentChange" @size-change="sizeChange"></el-pagination>
    </el-dialog>
  </div>

</template>

<script>
const initInfo = {
  goodsId: '',
  name: '',
  getPrice: '',
  salePrice: '',
  goodsNum: '',
  getMan: '',
  goodsTime: '',
  status: ''
}
export default {
  name: 'showGoods',
  data () {
    return {
      goodsForm: {
        ...initInfo
      },
      dataList: [],
      visible: false,
      pageIndex: 1,
      pageSize: 5,
      totalPage: 0
    }
  },
  methods: {
    showGoods (prospecId) {
      this.visible = true
      this.goodsForm = { ...initInfo }
      this.$http.get('/goodsSpec/showGoods/' + prospecId)
        .then(data => {
          if (data.code === 0) {
            this.dataList = data.list.list
            this.totalPage = data.list.totalCount
          } else {
            this.$message.error('数据加载失败，请重试！')
          }
        })
    },
    currentChange (val) {
      this.pageIndex = val
      this.showGoods()
    },
    sizeChange (val) {
      this.pageSize = val
      this.showGoods()
    }
  }
}
</script>

<style scoped>

</style>
